﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using Justin.Wcf.Services;

namespace Demo.QueryMetadata
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri mexAddress = new Uri("net.tcp://localhost:8000/mex/");

            //#region Query contract address
            //MetadataExchangeClient mexClient = new MetadataExchangeClient(mexAddress, MetadataExchangeClientMode.MetadataExchange);
            //MetadataSet metadata = mexClient.GetMetadata();
            //MetadataImporter importer = new WsdlImporter(metadata);
            //ServiceEndpointCollection endpoints = importer.ImportAllEndpoints();
            //System.Collections.ObjectModel.Collection<ContractDescription> contracts = importer.ImportAllContracts();
            //#endregion


            //#region Use the MetadataResolver Class to Query metadata
            //            ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(IB), mexAddress,  MetadataExchangeClientMode.MetadataExchange);
            //            Console.WriteLine(String.Format("Quantity of endpoints : {} ", endpoints.Count));
            //#endregion

            #region Use the MetadataHelper class
            //MetadataHelper.GetContracts(mexAddress);
            Console.WriteLine(MetadataHelper.QueryContract("net.tcp://localhost:8000/mex/", "Justin.Wcf.Services", "IB"));
            Console.ReadKey();
            #endregion
        }
    }
}
